package com.his.service.impl;

import com.his.entity.OrderCategory;
import com.his.mapper.OrderCategoryMapper;
import com.his.service.OrderCategoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (OrderCategory)表服务实现类
 *
 * @author makejava
 * @since 2020-10-23 18:14:11
 */
@Service("orderCategoryService")
public class OrderCategoryServiceImpl implements OrderCategoryService {
    @Resource
    private OrderCategoryMapper orderCategoryMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public OrderCategory queryById(Integer id) {
        return this.orderCategoryMapper.queryById(id);
    }

    /**
     * 查询所有通过实体类属性
     *
     * @param orderCategory 实例对象
     * @return 查询的结果
     */
    @Override
    public List<OrderCategory> queryAll(OrderCategory orderCategory) {
        return this.orderCategoryMapper.queryAll(orderCategory);
    }

    /**
     * 新增数据
     *
     * @param orderCategory 实例对象
     * @return 实例对象
     */
    @Override
    public OrderCategory insert(OrderCategory orderCategory) {
        this.orderCategoryMapper.insert(orderCategory);
        return orderCategory;
    }

    /**
     * 修改数据
     *
     * @param orderCategory 实例对象
     * @return 实例对象
     */
    @Override
    public OrderCategory update(OrderCategory orderCategory) {
        this.orderCategoryMapper.update(orderCategory);
        return this.queryById(orderCategory.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.orderCategoryMapper.deleteById(id) > 0;
    }
}